<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>目标7步制定法 - 职场观察者知识库工具</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/lucide@latest"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700&family=Source+Han+Sans+CN:wght@300;400;700&display=swap" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#3B82F6',
                        secondary: '#10B981',
                        'highlight-bg': '#EFF6FF',
                        'highlight-text': '#1E40AF',
                    }
                }
            }
        }
    </script>
    <style>
        :root {
            --theme-primary: #3B82F6;
            --theme-secondary: #10B981;
            --highlight-bg: #EFF6FF;
            --highlight-text: #1E40AF;
        }
        body {
            font-family: 'Source Han Sans CN', sans-serif;
            font-weight: 300;
        }
        h1, h2, h3, blockquote {
            font-family: 'Noto Serif SC', serif;
        }
        .magazine-page {
            width: 700px;
            background: #fefefe;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-height: auto;
        }
        .dark .magazine-page {
            background: #111827;
        }
        .dark p {
            color: #d1d5db;
        }
        .dark h1, .dark h2, .dark h3 {
            color: #f9fafb;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            font-family: 'Noto Serif SC', serif;
        }
        .breathing-space {
            letter-spacing: 0.05em;
            line-height: 1.8;
        }
        .seven-steps-table {
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 1.5rem;
        }
        .seven-steps-table th, .seven-steps-table td {
            border: 1px solid #e5e7eb;
            padding: 0.75rem;
            text-align: left;
        }
        .seven-steps-table th {
            background-color: #f9fafb;
            font-weight: 600;
        }
        .editable {
            min-height: 40px;
            padding: 0.5rem;
            border: 1px dashed #d1d5db;
            border-radius: 0.25rem;
            transition: all 0.3s ease;
        }
        .editable:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
            background-color: #f8fafc;
        }
        .seven-steps-card {
            background: white;
            border-radius: 0.5rem;
            box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
            padding: 1.5rem;
            margin-bottom: 1.5rem;
        }
        .seven-steps-card h3 {
            color: #1e40af;
            border-bottom: 2px solid #e5e7eb;
            padding-bottom: 0.5rem;
            margin-bottom: 1rem;
        }
        .method-explanation {
            background-color: #f0f9ff;
            border-left: 4px solid #3b82f6;
            padding: 1rem;
            margin-bottom: 1.5rem;
            border-radius: 0 0.5rem 0.5rem 0;
        }
        .input-hint {
            font-size: 0.75rem;
            color: #6b7280;
            margin-top: 0.25rem;
        }
        .save-indicator {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: #10b981;
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .save-indicator.show {
            opacity: 1;
        }
        .objective-section {
            margin-bottom: 2rem;
        }
        .step-item {
            margin-bottom: 1.5rem;
            padding-bottom: 1.5rem;
            border-bottom: 1px solid #e5e7eb;
        }
        .step-item:last-child {
            border-bottom: none;
        }
        .step-number {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 28px;
            height: 28px;
            background-color: #3b82f6;
            color: white;
            border-radius: 50%;
            font-weight: bold;
            margin-right: 0.75rem;
        }
        .step-title {
            font-weight: 600;
            color: #374151;
            margin-bottom: 0.5rem;
        }
        /* 为PDF导出添加的留白样式 */
        .pdf-footer-space {
            height: 120px; /* 三行留白的高度 */
            width: 100%;
        }
        /* 新的表格样式 */
        .goal-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 1.5rem;
        }
        .goal-table th, .goal-table td {
            border: 1px solid #e5e7eb;
            padding: 0.75rem;
            text-align: left;
            vertical-align: top;
        }
        .goal-table th {
            background-color: #f9fafb;
            font-weight: 600;
            width: 25%;
        }
        .goal-table .sub-goal-row {
            background-color: #f8fafc;
        }
        .add-button {
            background-color: #10b981;
            color: white;
            border: none;
            border-radius: 0.375rem;
            padding: 0.5rem 1rem;
            font-size: 0.875rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            margin-top: 1rem;
        }
        .add-button:hover {
            background-color: #059669;
        }
        .delete-button {
            background-color: #ef4444;
            color: white;
            border: none;
            border-radius: 0.375rem;
            padding: 0.25rem 0.5rem;
            font-size: 0.75rem;
            cursor: pointer;
            margin-left: 1rem;
        }
        .delete-button:hover {
            background-color: #dc2626;
        }
        .goal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }
    </style>
</head>
<body class="bg-gray-100 dark:bg-gray-800 flex items-center justify-center min-h-screen p-4 md:p-8">
    <article class="magazine-page shadow-2xl p-8">
        <!-- 页面头部 -->
        <header class="mb-8">
            <h1 class="text-3xl font-bold leading-tight mb-2 relative">
                <span class="absolute left-0 -top-2 bottom-2 w-1.5 bg-primary rounded-full"></span>
                <span class="ml-6">目标7步制定法</span>
            </h1>
            <p class="text-lg text-gray-600 dark:text-gray-400 font-light ml-6">系统化制定和实现目标的完整方法论</p>
        </header>

        <!-- 方法说明 -->
        <div class="method-explanation">
            <h3 class="font-bold text-primary mb-2">目标7步制定法简介</h3>
            <p class="text-gray-700">目标7步制定法是一种系统化的目标管理方法，通过七个关键步骤帮助您从愿景分析到行动方案的完整规划。这种方法确保您的目标不仅明确具体，而且具备可执行性和可持续性。</p>
        </div>

        <!-- 导出按钮 -->
        <div class="flex justify-end mb-6 gap-3">
            <button id="export-pdf" class="bg-red-500 hover:bg-red-600 text-white font-medium py-2 px-4 rounded-lg transition duration-300 flex items-center">
                <i data-lucide="file-text" class="w-5 h-5 mr-2"></i>
                导出为PDF
            </button>
            <button id="export-doc" class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg transition duration-300 flex items-center">
                <i data-lucide="download" class="w-5 h-5 mr-2"></i>
                导出为文档
            </button>
        </div>

        <!-- 目标7步制定法内容 -->
        <div id="seven-steps-content">
            <div class="seven-steps-card">
                <h3 class="text-xl font-bold flex items-center">
                    <i data-lucide="target" class="w-6 h-6 mr-2 text-primary"></i>
                    目标7步制定法
                </h3>
                
                <div class="objective-section">
                    <label class="block text-sm font-medium text-gray-700 mb-1">Objective 目标</label>
                    <div class="editable" contenteditable="true" data-placeholder="请输入您的核心目标..."></div>
                    <div class="input-hint">设定一个清晰、有挑战性的目标，描述您想要实现的结果</div>
                </div>
                
                <div class="step-item">
                    <div class="step-title">
                        <span class="step-number">1</span>
                        Vision Analysis 愿景分析
                    </div>
                    <div class="editable" contenteditable="true" data-placeholder="请分析您的长期愿景和理想状态..."></div>
                    <div class="input-hint">明确您的长期愿景，描述实现目标后的理想状态</div>
                </div>
                
                <div class="step-item">
                    <div class="goal-header">
                        <div class="step-title">
                            <span class="step-number">2</span>
                            Quantifiable 可量化
                        </div>
                        <button id="add-sub-goal" class="add-button">
                            <i data-lucide="plus" class="w-4 h-4 mr-1"></i>
                            添加子目标
                        </button>
                    </div>
                    
                    <table class="goal-table">
                        <thead>
                            <tr>
                                <th>子目标/任务</th>
                                <th>量化指标</th>
                                <th>目标值</th>
                                <th>截止日期</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="sub-goals-container">
                            <tr class="sub-goal-row">
                                <td>
                                    <div class="editable" contenteditable="true" data-placeholder="子目标描述..."></div>
                                </td>
                                <td>
                                    <div class="editable" contenteditable="true" data-placeholder="量化指标..."></div>
                                </td>
                                <td>
                                    <div class="editable" contenteditable="true" data-placeholder="目标数值..."></div>
                                </td>
                                <td>
                                    <div class="editable" contenteditable="true" data-placeholder="YYYY-MM-DD"></div>
                                </td>
                                <td>
                                    <button class="delete-button">删除</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="input-hint">将目标分解为具体的子目标和可衡量的指标，确保每个子目标都有明确的截止日期</div>
                </div>
                
                <div class="step-item">
                    <div class="step-title">
                        <span class="step-number">3</span>
                        Barrier Analysis 障碍分析
                    </div>
                    <div class="editable" contenteditable="true" data-placeholder="请分析可能遇到的障碍和挑战..."></div>
                    <div class="input-hint">识别实现目标过程中可能遇到的内外部障碍和挑战</div>
                </div>
                
                <div class="step-item">
                    <div class="step-title">
                        <span class="step-number">4</span>
                        Capability Analysis 能力分析
                    </div>
                    <div class="editable" contenteditable="true" data-placeholder="请评估您当前的能力和技能水平..."></div>
                    <div class="input-hint">评估您当前的能力状况，识别需要提升的技能和知识</div>
                </div>
                
                <div class="step-item">
                    <div class="step-title">
                        <span class="step-number">5</span>
                        Resource Analysis 资源分析
                    </div>
                    <div class="editable" contenteditable="true" data-placeholder="请分析所需的资源和现有资源..."></div>
                    <div class="input-hint">明确实现目标所需的各种资源，包括时间、资金、人脉等</div>
                </div>
                
                <div class="step-item">
                    <div class="step-title">
                        <span class="step-number">6</span>
                        Action Plan 行动方案
                    </div>
                    <div class="editable" contenteditable="true" data-placeholder="请制定具体的行动步骤和计划..."></div>
                    <div class="input-hint">将目标分解为具体的、可执行的行动步骤和计划</div>
                </div>
                
                <div class="step-item">
                    <div class="step-title">
                        <span class="step-number">7</span>
                        Progress Tracking 进度跟踪
                    </div>
                    <div class="editable" contenteditable="true" data-placeholder="请设计进度跟踪机制..."></div>
                    <div class="input-hint">设计如何定期检查进度、评估效果和调整计划的机制</div>
                </div>
            </div>
            
            <!-- 使用提示 -->
            <div class="seven-steps-card bg-yellow-50 border border-yellow-200">
                <h3 class="text-lg font-bold text-yellow-800 flex items-center">
                    <i data-lucide="lightbulb" class="w-5 h-5 mr-2"></i>
                    目标7步制定法使用提示
                </h3>
                <ul class="text-yellow-700 text-sm list-disc pl-5 space-y-1">
                    <li>按顺序完成每个步骤，确保目标制定的系统性</li>
                    <li>愿景分析要具体且富有感染力，能够激发内在动力</li>
                    <li>量化指标要具体明确，便于跟踪和评估进度</li>
                    <li>时间节点要合理设定，既要有挑战性又要可实现</li>
                    <li>障碍分析要全面客观，提前制定应对策略</li>
                    <li>定期回顾和调整计划，保持灵活性和适应性</li>
                </ul>
            </div>
            
            <!-- PDF导出留白区域 -->
            <div class="pdf-footer-space"></div>
        </div>

        <!-- 页面底部信息 -->
        <div class="flex items-center text-green-600 mt-8 pt-6 border-t border-gray-200 dark:border-gray-700">
            <i data-lucide="check-circle" class="w-5 h-5 mr-2"></i>
            <span>目标7步制定法 · 职场观察者知识库工具</span>
        </div>
        
        <!-- 保存提示 -->
        <div id="save-indicator" class="save-indicator">
            <i data-lucide="check" class="w-4 h-4 mr-1 inline"></i>
            内容已自动保存
        </div>
    </article>

    <script>
        // 初始化Lucide图标
        lucide.createIcons();
        
        // 设置占位符文本
        document.querySelectorAll('.editable').forEach(editable => {
            const placeholder = editable.getAttribute('data-placeholder');
            if (placeholder && !editable.textContent.trim()) {
                editable.textContent = placeholder;
                editable.classList.add('text-gray-400');
            }
            
            editable.addEventListener('focus', function() {
                if (this.textContent === this.getAttribute('data-placeholder')) {
                    this.textContent = '';
                    this.classList.remove('text-gray-400');
                }
            });
            
            editable.addEventListener('blur', function() {
                if (!this.textContent.trim()) {
                    this.textContent = this.getAttribute('data-placeholder');
                    this.classList.add('text-gray-400');
                }
            });
            
            // 自动保存功能
            editable.addEventListener('input', function() {
                clearTimeout(this.saveTimeout);
                this.saveTimeout = setTimeout(() => {
                    showSaveIndicator();
                }, 1000);
            });
        });
        
        // 添加子目标
        document.getElementById('add-sub-goal').addEventListener('click', function() {
            const container = document.getElementById('sub-goals-container');
            const newRow = document.createElement('tr');
            newRow.className = 'sub-goal-row';
            newRow.innerHTML = `
                <td>
                    <div class="editable" contenteditable="true" data-placeholder="子目标描述..."></div>
                </td>
                <td>
                    <div class="editable" contenteditable="true" data-placeholder="量化指标..."></div>
                </td>
                <td>
                    <div class="editable" contenteditable="true" data-placeholder="目标数值..."></div>
                </td>
                <td>
                    <div class="editable" contenteditable="true" data-placeholder="YYYY-MM-DD"></div>
                </td>
                <td>
                    <button class="delete-button">删除</button>
                </td>
            `;
            container.appendChild(newRow);
            
            // 初始化新添加的可编辑区域
            newRow.querySelectorAll('.editable').forEach(editable => {
                const placeholder = editable.getAttribute('data-placeholder');
                editable.textContent = placeholder;
                editable.classList.add('text-gray-400');
                
                editable.addEventListener('focus', function() {
                    if (this.textContent === this.getAttribute('data-placeholder')) {
                        this.textContent = '';
                        this.classList.remove('text-gray-400');
                    }
                });
                
                editable.addEventListener('blur', function() {
                    if (!this.textContent.trim()) {
                        this.textContent = this.getAttribute('data-placeholder');
                        this.classList.add('text-gray-400');
                    }
                });
            });
            
            // 删除按钮功能
            newRow.querySelector('.delete-button').addEventListener('click', function() {
                container.removeChild(newRow);
            });
        });
        
        // 初始化删除按钮功能
        document.querySelectorAll('.delete-button').forEach(button => {
            button.addEventListener('click', function() {
                const row = this.closest('tr');
                if (row && row.parentNode) {
                    row.parentNode.removeChild(row);
                }
            });
        });
        
        // 显示保存提示
        function showSaveIndicator() {
            const indicator = document.getElementById('save-indicator');
            indicator.classList.add('show');
            setTimeout(() => {
                indicator.classList.remove('show');
            }, 2000);
        }
        
        // 导出为PDF功能
        document.getElementById('export-pdf').addEventListener('click', function() {
            const { jsPDF } = window.jspdf;
            
            // 获取要导出的内容
            const element = document.getElementById('seven-steps-content');
            
            // 临时移除占位符文本和删除按钮
            document.querySelectorAll('.editable').forEach(editable => {
                if (editable.textContent === editable.getAttribute('data-placeholder')) {
                    editable.textContent = '';
                }
            });
            
            // 隐藏删除按钮
            const deleteButtons = document.querySelectorAll('.delete-button');
            deleteButtons.forEach(button => {
                button.style.display = 'none';
            });
            
            // 使用html2canvas将内容转换为图片
            html2canvas(element, {
                scale: 2,
                useCORS: true,
                logging: false
            }).then(canvas => {
                const imgData = canvas.toDataURL('image/png');
                const pdf = new jsPDF('p', 'mm', 'a4');
                const imgWidth = 190; // 页面宽度
                const pageHeight = 277; // A4高度
                const imgHeight = canvas.height * imgWidth / canvas.width;
                let heightLeft = imgHeight;
                let position = 10;
                
                // 计算每页需要留白的高度（三行）
                const lineHeight = 6; // 估算一行的高度（毫米）
                const marginBottom = lineHeight * 3; // 三行留白
                
                // 第一页
                pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
                heightLeft -= (pageHeight - marginBottom);
                
                // 如果内容超过一页，添加新页面
                while (heightLeft >= 0) {
                    position = - (pageHeight - marginBottom - 10); // 调整位置
                    pdf.addPage();
                    pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
                    heightLeft -= (pageHeight - marginBottom);
                }
                
                pdf.save('目标7步制定法.pdf');
                
                // 恢复占位符文本和删除按钮
                document.querySelectorAll('.editable').forEach(editable => {
                    if (!editable.textContent.trim()) {
                        editable.textContent = editable.getAttribute('data-placeholder');
                        editable.classList.add('text-gray-400');
                    }
                });
                
                // 恢复删除按钮
                deleteButtons.forEach(button => {
                    button.style.display = 'inline-block';
                });
            });
        });

        // 导出为文档功能
        document.getElementById('export-doc').addEventListener('click', function() {
            // 创建一个临时的div来保存格式化内容
            const tempDiv = document.createElement('div');
            tempDiv.innerHTML = document.getElementById('seven-steps-content').innerHTML;
            
            // 获取所有可编辑区域的内容
            const editables = tempDiv.querySelectorAll('[contenteditable="true"]');
            editables.forEach(editable => {
                // 移除contenteditable属性
                editable.removeAttribute('contenteditable');
                // 如果内容是占位符，清空
                if (editable.textContent === editable.getAttribute('data-placeholder')) {
                    editable.textContent = '';
                }
                // 添加样式以保持格式
                editable.style.border = '1px solid #ddd';
                editable.style.padding = '8px';
                editable.style.minHeight = '40px';
                editable.style.marginBottom = '10px';
            });
            
            // 移除添加按钮
            const addButton = tempDiv.querySelector('#add-sub-goal');
            if (addButton) addButton.remove();
            
            // 移除删除按钮
            const deleteButtons = tempDiv.querySelectorAll('.delete-button');
            deleteButtons.forEach(button => button.remove());
            
            // 创建HTML内容
            const htmlContent = `
                <!DOCTYPE html>
                <html>
                <head>
                    <meta charset="UTF-8">
                    <title>目标7步制定法</title>
                    <style>
                        body { 
                            font-family: 'Source Han Sans CN', sans-serif; 
                            margin: 20px;
                            color: #333;
                        }
                        h1, h2, h3 { 
                            font-family: 'Noto Serif SC', serif; 
                            color: #1e40af;
                        }
                        h1 { font-size: 24px; border-bottom: 2px solid #1e40af; padding-bottom: 10px; }
                        h3 { font-size: 18px; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; }
                        .seven-steps-card { 
                            margin-bottom: 30px; 
                            padding: 20px; 
                            border: 1px solid #ddd; 
                            border-radius: 5px; 
                        }
                        .method-explanation {
                            background-color: #f0f9ff;
                            border-left: 4px solid #3b82f6;
                            padding: 15px;
                            margin-bottom: 20px;
                        }
                        .objective-section {
                            margin-bottom: 20px;
                        }
                        .step-item {
                            margin-bottom: 20px;
                            padding-bottom: 20px;
                            border-bottom: 1px solid #e5e7eb;
                        }
                        .step-item:last-child {
                            border-bottom: none;
                        }
                        .step-number {
                            display: inline-flex;
                            align-items: center;
                            justify-content: center;
                            width: 28px;
                            height: 28px;
                            background-color: #3b82f6;
                            color: white;
                            border-radius: 50%;
                            font-weight: bold;
                            margin-right: 0.75rem;
                        }
                        .step-title {
                            font-weight: 600;
                            color: #374151;
                            margin-bottom: 10px;
                        }
                        .goal-table {
                            width: 100%;
                            border-collapse: collapse;
                            margin-bottom: 15px;
                        }
                        .goal-table th, .goal-table td {
                            border: 1px solid #ddd;
                            padding: 10px;
                            text-align: left;
                            vertical-align: top;
                        }
                        .goal-table th {
                            background-color: #f2f2f2;
                            font-weight: 600;
                            width: 25%;
                        }
                        .goal-table .sub-goal-row {
                            background-color: #f8fafc;
                        }
                        .pdf-footer-space {
                            height: 120px;
                            width: 100%;
                        }
                    </style>
                </head>
                <body>
                    <h1>目标7步制定法</h1>
                    <div class="method-explanation">
                        <h3>目标7步制定法简介</h3>
                        <p>目标7步制定法是一种系统化的目标管理方法，通过七个关键步骤帮助您从愿景分析到行动方案的完整规划。这种方法确保您的目标不仅明确具体，而且具备可执行性和可持续性。</p>
                    </div>
                    ${tempDiv.innerHTML}
                </body>
                </html>
            `;
            
            // 创建Blob并下载
            const blob = new Blob([htmlContent], { type: 'application/msword' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = '目标7步制定法.doc';
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            URL.revokeObjectURL(url);
        });
    </script>
</body>
</html>